package com.ruoyi.column.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.column.domain.EColumn;
import com.ruoyi.column.service.IEColumnService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 栏目管理Controller
 *
 * @author ruoyi
 * @date 2024-11-23
 */
@RestController
@RequestMapping("/column")
public class EColumnController extends BaseController
{
    @Autowired
    private IEColumnService eColumnService;

    /**
     * 查询栏目管理列表
     */
    @RequiresPermissions("column:column:list")
    @GetMapping("/list")
    public TableDataInfo list(EColumn eColumn)
    {
        startPage();
        List<EColumn> list = eColumnService.selectEColumnList(eColumn);
        return getDataTable(list);
    }

    /**
     * 导出栏目管理列表
     */
    @RequiresPermissions("column:column:export")

    @PostMapping("/export")
    public void export(HttpServletResponse response, EColumn eColumn)
    {
        List<EColumn> list = eColumnService.selectEColumnList(eColumn);
        ExcelUtil<EColumn> util = new ExcelUtil<EColumn>(EColumn.class);
        util.exportExcel(response, list, "栏目管理数据");
    }

    /**
     * 获取栏目管理详细信息
     */
    @RequiresPermissions("column:column:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(eColumnService.selectEColumnById(id));
    }

    /**
     * 新增栏目管理
     */
    @RequiresPermissions("column:column:add")

    @PostMapping
    public AjaxResult add(@RequestBody EColumn eColumn)
    {
        return toAjax(eColumnService.insertEColumn(eColumn));
    }

    /**
     * 修改栏目管理
     */
    @RequiresPermissions("column:column:edit")

    @PutMapping
    public AjaxResult edit(@RequestBody EColumn eColumn)
    {
        return toAjax(eColumnService.updateEColumn(eColumn));
    }

    /**
     * 删除栏目管理
     */
    @RequiresPermissions("column:column:remove")

	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(eColumnService.deleteEColumnByIds(ids));
    }
}
